﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public  class BordWidthDAL:DALBase
    {
        private static ObjectQuery<BoardWidth> GetBordWidth()
        {
            return DataEntites.BoardWidth;
        }


        /// <summary>
        /// Get BoardWidth List
        /// </summary>
        /// <returns></returns>
        public static List<BoardWidth> GetBordWidthList()
        {
            List<BoardWidth> list = new List<BoardWidth>();
            try
            {
                foreach (var item in GetBordWidth())
                {
                    list.Add(item);
                }
            }
            catch (Exception e)
            { 
            }
            return list;
        }
        /// <summary>
        /// Get BoardWidth obj
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static BoardWidth GetBordWidthObj(double width)
        {
            return DataEntites.BoardWidth.First(b => b.Width == width);
        }

        /// <summary>
        /// Get BoardWidth obj
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static BoardWidth GetBordWidthObj(int  id)
        {
            return DataEntites.BoardWidth.First(b => b.BoardWidthID ==id);
        }


        /// <summary>
        /// Get BoardWidth obj
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static BoardWidth GetBordWidthObj()
        {
            return DataEntites.BoardWidth.First();
        }

        public static void Add(BoardWidth obj)
        {
            DataEntites.AddToBoardWidth(obj);
            DataEntites.SaveChanges();
        }

        public static void Update()
        {
            DataEntites.SaveChanges();
        }

        public static void Delete(BoardWidth obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }
    }
}
